﻿////////////////////////////////////////////////////////////////////////////////
// Source Copyright (C) J.Fan
// @author      J.Fan
// @date        2013-01-19
// @revision    Revision in Version Control System
// @remark      
////////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JsonConverter.Converter
{
    class InternalConverterProvider: ConverterProvider
    {
        const string CannotUnregisterMessage
            = "cannot remove converter from internal provider";

        public static InternalConverterProvider Instance { get; private set; }

        static InternalConverterProvider()
        {
            Instance = new InternalConverterProvider();
            Instance.Register(new PrimitiveConverter(),
                typeof(byte), typeof(sbyte), typeof(short), typeof(ushort),
                typeof(int), typeof(uint), typeof(long), typeof(ulong),
                typeof(float), typeof(double), typeof(decimal),
                typeof(bool), typeof(char),
                typeof(IntPtr), typeof(UIntPtr));
            Instance.Register(new StringConverter(), typeof(string));
            Instance.Register(new DateTimeFormatConverter(), typeof(DateTime));

            // more converters should be registered
            // StringObjectDictionaryConverter
            // EnumeratableConverter
            // CustomerObjectConverter
        }

        public IObjectConverter CustomObjectConverter { get; private set; }

        public override void UnregisterPrimitiveConverter(Type type)
        {
            throw new InvalidOperationException(CannotUnregisterMessage);
        }

        public override void UnregisterPrimitiveConverter(params Type[] types)
        {
            throw new InvalidOperationException(CannotUnregisterMessage);
        }

        public override void UnregisterObjectConverter(Type type)
        {
            throw new InvalidOperationException(CannotUnregisterMessage);
        }

        public override void UnregisterObjectConverter(params Type[] types)
        {
            throw new InvalidOperationException(CannotUnregisterMessage);
        }
    }
}
